<template>
  <n-date-picker
    type="daterange"
    size="small"
    format="yyyy/MM/dd"
    :close-on-select="true"
    clearable
    :shortcuts="rangeShortcuts"
  />
</template>

<script setup lang="ts">
const rangeShortcuts = {
  近30天: () => {
    const cur = new Date().getTime();
    return [cur - 30 * 24 * 60 * 60 * 1000, cur] as const;
  },
  近7天: () => {
    const cur = new Date().getTime();
    return [cur - 7 * 24 * 60 * 60 * 1000, cur] as const;
  },
  近3天: () => {
    const cur = new Date().getTime();
    return [cur - 3 * 24 * 60 * 60 * 1000, cur] as const;
  },
  本月: () => {
    const now = new Date();
    const cur = now.getTime();
    const nowDay = now.getDate() - 1;
    return [cur - nowDay * 24 * 60 * 60 * 1000, cur] as const;
  }
};
</script>

<style scoped></style>
